<?php
// +----------------------------------------------------------------------
// | quanli team
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2020 http://www.fistforward.com/ All rights reserved.
// +----------------------------------------------------------------------
// | Author: create by allen.qiang
// +----------------------------------------------------------------------

/**
 * 资源位ajax类
 * @package  	ajax
 * @subpackage  backend
 * @author   	allen.qiang
 */
quanli_require('module/base/billHandler.class.php');

class ajax_billWarning {
    public function execute() {
        if (isset($_REQUEST['operFlg']) && $_REQUEST['operFlg'] > 0) {
            switch($_REQUEST['operFlg']) {
                case 1: //查询异常物流订单
                    $this->searchBillWarning();
                    break;
            }
            
        }
        
    }


    /**
     * 查询资源位分类信息
     */
    private function searchBillWarning() {

        global $G_PGLOB;

        //实例化资源位类
        $billHandler = new billHandler( $G_PGLOB->DBCA );

        $bill_info_array = $billHandler->searchBillWarning( $_REQUEST );
		
        //组织返回的数据
        $result_array = array(
            'page'  => $_REQUEST['page'],
            'total' => $_REQUEST['count'],
            'rows'  => array()
        );

        if ($bill_info_array) {
            foreach($bill_info_array as &$bill) {
            	$freight_state = '';
            	
            	if($bill->freight_state == 0)
            		$freight_state = '在途';
            	elseif($bill->freight_state == 1)
            		$freight_state = '揽件';
            	elseif($bill->freight_state == 2)	
            		$freight_state = '疑难';
            	elseif($bill->freight_state == 3)		
            		$freight_state = '签收';
            	elseif($bill->freight_state == 4)		
            		$freight_state = '退签';	
            	elseif($bill->freight_state == 5)		
            		$freight_state = '派件';	
            	elseif($bill->freight_state == 6)		
            		$freight_state = '退回';

                //订单类型（来源）数组
                $bill_type_array = array(
                    '1' => 'B2C商城',
                    '2' => '天猫商城',
                    '3' => '京东商城',
                    '4' => '1号店',
                    '5' => 'QQ网购',
                    '6' => '凡客',
                    '7' => '苏宁易购',
                    '8' => '实体店',
                    '9' => '补货单',
                    '10' => '换货单'
                );
            		
                $result_array['rows'][] = array(
                    'id' => $bill->bill_no,
                    'cell' => array(
                        $bill->bill_no ,
                        $bill_type_array[$bill->billType] ,
                        decryptD($bill->deliver_name) ,
                        decryptD($bill->deliver_mobile) ,
						decryptD($bill->deliver_address) ,
						'<font color="red">' . $bill->freight_company_name . '</font>',
						'<font color="red">' . $bill->freight_bill_no . '</font>',
						'<font color="red">' . $freight_state . '</font>', 
                        $bill->context
                    )
                );
            }
        }
		
        echo json_encode($result_array);

    }
    

}